<div class="nav-sub w1180">
	<ul class="zoom">
		<li><a class="on" href="">新增溯源报告</a></li>
		<li><a href="/crm/material/catelog-list">溯源类型列表</a></li>
		<li><a href="/crm/material/cate-list">溯源类目列表</a></li>
		<li><a href="/crm/material/list">溯源列表</a></li>
		<li><a href="/crm/material/report-list">溯源报告列表</a></li>
	</ul>
</div>
<div class="main-ct w1180">
	<a href="javascript:history.go(-1);" class="btn-cs btn-blue btn-fillet mt10">返 回</a>
	<form id="commonForm" method="post" action="/crm/material/insert-report">
		<div class="form-info mt20">
			<dl>
				<dt>溯源材料：</dt>
				<dd>
					<select name="material_id" id="material_id">
					<?php if ($this->material):?>
    				<?php foreach ($this->material as $k=>$v):?>
        				<option value="<?php echo $v['material_id']; ?>"><?php echo $v['material_name']; ?></option>
        			<?php endforeach; ?>
        			<?php else:?>
        				<option value="">请选择</option>
    				<?php endif;?>
    			</select>
				</dd>
			</dl>

			<dl>
				<dt>报告图片：</dt>
				<dd class="goods-list">
					<div class="goods-img goods-img-add" id="goods-thumb-image">
						<div class="g-img-ct" id="cover">
							<img src="/images/ico/ico-add.png" id="add-goods-thumb-image"> 
							<input type="hidden" name="image" id="product_thumb_image">
						</div>
						<a href="javascript:delImg(this);" class="btn-del" id="del-goods-thumb-image" style="display: none"></a>
					</div>
				</dd>
			</dl>

		</div>
		<p class="mt30 txt-center">
			<input class="input-cs btn-fillet btn-green" type="submit" value="确定" />
			<input class="input-cs btn-fillet mr20" type="reset" value="取消" />
		</p>
	</form>
</div>
<script type="text/javascript" src="/plugins/webUpload/webuploader.js"></script>
<script type="text/javascript">
	var uploader = WebUploader.create({

		// 选完文件后，是否自动上传。
		auto: true,
		duplicate:1,
		swf:'/plugins/webUpload/Uploader.swf',
		// 文件接收服务端。
		server: '/crm/product/upload',
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: {
			id:'#cover',
			multiple:false
		},
		formData :{
			path:"/report",
		},
		method : 'post',
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,png',
			mimeTypes: 'image/*'
		}
	});
	uploader.on('uploadSuccess',function(file,response){
		//alert(file.id);
		console.log(file);
		console.log(response);
		if(response.state == 'SUCCESS'){
	 		$('#add-goods-thumb-image').attr("src",response.url);
	 		$('#product_thumb_image').val(response.url);
	 		$('#del-goods-thumb-image').show();
			
		}
	});

	
	$().ready(function() {
		$("#commonForm").validate({
			debug:true,
			rules: {
			
		
			},
    		submitHandler:function(form){ 
    	            form.submit();
    	    }   
		});

	});
</script>